<%@ page contentType="text/html; charset=GBK" %>
<%@ page import="java.io.*" %>
<%@ include file="/common/inc.jsp" %>
<%
String id = request.getParameter("id");

Object o = session.getAttribute(id);
        String fileName = request.getParameter("filename");
        String strDownload = request.getParameter("download");
        String imageType = request.getParameter("type");
        if (imageType == null) imageType = "";
        if (imageType.equals("")) imageType = "png";
        boolean isDownload = false;
        if ((strDownload!=null) && (strDownload.equalsIgnoreCase("true")))
          isDownload = true;
        if (fileName == null) fileName = "";
        if (fileName.indexOf(".")<0)
          fileName = fileName + "."+ imageType;
        out.clearBuffer();
        response.setContentType("image/"+imageType);
        if (isDownload) {
          response.setHeader("Content-Disposition","attachment; filename="+fileName);
        }
        ByteArrayOutputStream imageStream = (ByteArrayOutputStream)o;
        ServletOutputStream streamOut = response.getOutputStream();
        imageStream.writeTo(streamOut);
        streamOut.close();
%>
